﻿using Microsoft.Extensions.DependencyInjection;
using ZeroBug.EasyFlow.Communication;
using ZeroBug.EasyFlow.Core;
using ZeroBug.EasyFlow.Motion;

namespace ZeroBug.EasyFlow.Machine
{
    public class LocalMachine
    {
        public static IServiceProvider Services { get; }
        static LocalMachine()
        {
            Services = ConfigureServices();
        }
        private static IServiceProvider ConfigureServices()
        {
            var services = new ServiceCollection();

            services.AddSingleton<LogHelper>();
            services.AddSingleton<AssemblyHelper>();
            services.AddSingleton<MachineResource<Axis, IAxis>>();
            services.AddSingleton<MachineResource<Sensor, IDigitalIO>>();
            services.AddSingleton<MachineResource<Cylinder, IDigitalIO>>();
            services.AddSingleton<MachineResource<Pdo, IPdo>>();
            services.AddSingleton<MachineResource<CommunicationClient, ICommunicationClient>>();

            return services.BuildServiceProvider();
        }
    }
}
